package test;

import lombok.NoArgsConstructor;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;

/**
 * @author lilingzhi
 * @since 2022/12/27 10:11
 */
public class LambdaTestDemo {


    /**
     * 对于复杂的lambda表达式而言 , 可以使用peek方法进行调试
     */
    @Test
    public void test(){
        List<Integer> list = Arrays.asList(1, 2, 3, null, 4, 5, 6, 7);
        list.stream()
                .peek(System.out::println)
                .map(x -> x++)
                .peek(System.out::println)
                .filter(x -> x % 2 == 0 )
                .peek(System.out::println)
                .limit(4)
                .peek(System.out::println)
                .forEach(System.out::println);

    }

    /**
     * 棱形问题 ：
     */
    @Test
    public void test1(){

    }





    public static void main(String[] args) {

    }
}


@NoArgsConstructor
class C  implements ADemo,BDemo{
    public static void main(String[] args) {
        new C().hello();
    }

    @Override
    public void hello() {
        ADemo.super.hello();
    }
}

interface ADemo{
    default void hello(){
        System.out.println("hello from a");
    };
}

interface BDemo{
    default void hello(){
        System.out.println("hello from b");
    };
}
class D implements ADemo{

    @Override
    public void hello() {
        System.out.println("hello --------->D");
    }
}
